/*! @amzn/apswebapstaglibrary - web-client-bundle - v24.910.1025 - 2024-09-10 10:25:15 */ !function(){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,o=arguments.length;n=0;c--)(r=t[c])&&(a=(i<3?r(a):i>3?r(e,n,a):r(e,n))||a);return i>3&&a&&Object.defineProperty(e,n,a),a}function r(t,e,n,o){return new(n||(n=Promise))((function(r,i){function a(t){try{u(o.next(t))}catch(t){i(t)}}function c(t){try{u(o.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}u((o=o.apply(t,e||[])).next())}))}function i(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&c[0]?o.return:c[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,c[1])).done)return r;switch(o=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,o=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,r,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(t){r={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return a}function u(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r=0&&t<=1?t:1};"number"==typeof(null==t?void 0:t.error)&&this._sampleRates.set("error",e(t.error)),"number"==typeof(null==t?void 0:t.feat)&&this._sampleRates.set("feat",e(t.feat))},t.prototype.clearAndUpdateEventProcessingInterval=function(t){var e=this;"number"!=typeof t||t<=0||t!==this._intervalDelayInMs&&(clearInterval(this._intervalId),this._intervalId=setInterval((function(){try{e.processEventRecords()}catch(t){}}),t),this._intervalDelayInMs=t)},t.prototype.processEventRecords=function(){for(var t=[],e=Array.from(this._recordQueues.keys()),n=function(n){var r=e[n],i=o._recordQueues.get(r),a=o._sampleRates.get(r);if(void 0===i||i.length<=0)return"continue";if(void 0===a||0===a)return i.length>=o._queueLimit&&(i.length=0,o.logEvent({eventCategory:r,eventName:"queue limit reached"})),"continue";var s=i.filter((function(t){return void 0!==t&&a>=Math.random()}));i.length=0,t.push.apply(t,u([],c(s),!1))},o=this,r=0;rthis.STACK_MAX_LENGTH){var e="[...]";return t.stack.substring(0,this.STACK_MAX_LENGTH-e.length)+e}return t.stack}catch(t){return"NO STACK: ERROR ON RETRIEVAL"}},t.prototype.getErrorName=function(t){var e="unknown";try{"string"==typeof t?e=t:void 0!==t.name&&(e=t.name)}catch(t){try{e="Client Error: ".concat(t.name.toString()," - ").concat(t.message)}catch(t){e="Client Error: Unable to provide more information"}}return e},t.prototype.getErrorMessage=function(t){var e="unknown";try{"string"==typeof t?e=t:void 0!==t.message&&(e=t.message)}catch(t){try{e="Client Error: ".concat(t.name.toString()," - ").concat(t.message)}catch(t){e="Client Error: Unable to provide more information"}}return e},t.prototype.getErrorContext=function(t){var e,n="unknown";try{"string"!=typeof t&&"context"in t&&(n=null!==(e=t.context)&&void 0!==e?e:"")}catch(t){try{n="Client Error: ".concat(t.name.toString()," - ").concat(t.message)}catch(t){n="Client Error: Unable to provide more information"}}return n},t}(),C=new x;!function(t){t.push="push",t.listenerSuccess="listenerSuccess",t.direct="direct"}(y||(y={})),function(t){t.internal="internal",t.apstag="apstag",t.webpage="webpage",t.dtbm="dtbm"}(b||(b={})),function(t){t.completed="completed",t.waiting="waiting",t.cancelled="cancelled"}(w||(w={})),function(t){t.started="started",t.error="error",t.unknown="unknown",t.deactivated="deactivated"}(E||(E={}));var I=n(n({},w),E),P=new Map([["_config/config/didLoad",function(t){var e=t.account;return t.customEvent,r(void 0,void 0,void 0,(function(){return i(this,(function(t){return e.write("config/loaded",!0),[2,w.completed]}))}))}],["_config/requestViewerCountry/define",function(t){var e=t.account,n=t.customEvent;return r(void 0,void 0,void 0,(function(){var t,o;return i(this,(function(r){if(void 0===(null===(o=n.detail)||void 0===o?void 0:o.code))throw new Error("Missing country code");if("string"!=typeof(t=n.detail.code)||0===t.trim().length)throw new Error('Invalid country code: "'.concat(t,'"'));return e.update(S,(function(){return t})),[2,w.completed]}))}))}]]),A="apstag/configuration/fetch",L=new Map([[A,function(t){var e=t.account;return t.customEvent,r(void 0,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return(t=e.globalContext.document.createElement("script")).setAttribute("src","".concat("https://config.aps.amazon-adsystem.com/configs/").concat(e.id)),t.setAttribute("type","text/javascript"),t.setAttribute("async","async"),e.globalContext.document.head.appendChild(t),[4,new Promise((function(e,n){t.addEventListener("load",(function(){e()})),t.addEventListener("error",(function(t){n(t)}))}))];case 1:return n.sent(),[2,w.completed]}}))}))}]]),k="consent/GPPData",D="consent/isGPPListenerRegistered",N={key:"consent/isTCFAPIListenerRegistered",default:!1},R={key:"consent/TCData",default:void 0};function O(t,e){var n,o;return"string"==typeof(null==e?void 0:e.tcString)&&(null==e?void 0:e.tcString.length)>0||!0===(null===(o=null===(n=null==t?void 0:t.globalContext)||void 0===n?void 0:n.apstag)||void 0===o?void 0:o.isGDPRRegion)||!0===(null==e?void 0:e.gdprApplies)}function j(t,e){var n,o,r,i,a;return!0===(null===(o=null===(n=t.vendor)||void 0===n?void 0:n.consents)||void 0===o?void 0:o[793])&&(i=e,a=null===(r=t.purpose)||void 0===r?void 0:r.consents,(null!=i?i:[]).reduce((function(t,e){return t&&!0===(null==a?void 0:a[e])}),!0))}var T=function(t,e){var o={tcData:e,consents:[1]},r=function(t){try{return t()}catch(t){return"error"}};return{tcT:r((function(){return t.isAPStagAllowedToAccessInfoOnDevice()})),tcCC:r((function(){return function(t){var e,n=t.account,o=t.tcData,r=t.consents;if(!O(n,o))return!0;if("object"!=typeof o)return!1;if((null!==(e=o.tcfPolicyVersion)&&void 0!==e?e:0)<2)return!1;if(o.useNonStandardStacks)return!1;if(!o.isServiceSpecific)return!1;var i=!1;return r.forEach((function(t){var e,n,a;switch(null===(a=null===(n=null===(e=o.publisher)||void 0===e?void 0:e.restrictions)||void 0===n?void 0:n[t])||void 0===a?void 0:a[793]){case 0:case 2:i=!0;break;default:j(o,r)||(i=!0)}})),!i}(n(n({},o),{account:t}))})),tcCF:r((function(){return 0===function(t){var e,n=t.tcData,o=t.consents;if(0===(null!=o?o:[]).length)return["No consents param passed"];var r=[];try{if("object"!=typeof n){var i="";try{i=JSON.stringify(n)}catch(t){}r.push("Invalid tcData: ".concat(i))}return!1===n.gdprApplies?[]:((null!==(e=n.tcfPolicyVersion)&&void 0!==e?e:0)<2&&r.push("tcData version not supported: ".concat(n.tcfPolicyVersion)),n.useNonStandardStacks&&r.push("tcData's useNonStandardStacks should not be true"),n.isServiceSpecific||r.push("tcData needs to be service specific"),o.forEach((function(t){var e,i,a;switch(null===(a=null===(i=null===(e=n.publisher)||void 0===e?void 0:e.restrictions)||void 0===i?void 0:i[t])||void 0===a?void 0:a[793]){case 0:r.push("Invalid publisher restrictions 0, consent ".concat(t));break;case 2:r.push("Invalid publisher restrictions 2, consent ".concat(t));break;default:j(n,o)||r.push("Invalid publisher restrictions default, consent ".concat(t))}})),r)}catch(t){if(r.length>0)return r;throw t}}(o).length})),PRA:r((function(){return O(t,e)}))}},M={consent_gppapi_attemptSync:"consent/gppapi/attemptSync",consent_gppapi_didChange:"consent/gppapi/didChange",consent_gppapi_syncData:"consent/gppapi/syncData",consent_tcfapi_attemptSync:"consent/tcfapi/attemptSync",consent_tcfapi_didChange:"consent/tcfapi/didChange"},U=new Map([[M.consent_gppapi_attemptSync,function(t){var e=t.account;return r(void 0,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return void 0===e.globalContext.__gpp||!0===e.read(D)?[2,w.cancelled]:[4,e.record(M.consent_gppapi_syncData)];case 1:return n.sent(),t=e.globalContext.__gpp("addEventListener",(function(t){"error"!==(null==t?void 0:t.eventName)&&e.record(M.consent_gppapi_didChange,{eventListener:t,fromAddEvent:!0}).catch((function(t){}))})),e.write(D,"listenerRegistered"===(null==t?void 0:t.eventName)&&!0===(null==t?void 0:t.data)),[2,w.completed]}}))}))}],[M.consent_gppapi_didChange,function(t){var e=t.account,n=t.customEvent;return r(void 0,void 0,void 0,(function(){var t,o;return i(this,(function(r){switch(r.label){case 0:return[4,e.record(M.consent_gppapi_syncData,{eventListener:null===(t=n.detail)||void 0===t?void 0:t.eventListener,fromAddEvent:null===(o=n.detail)||void 0===o?void 0:o.fromAddEvent})];case 1:return r.sent(),[2,w.completed]}}))}))}],[M.consent_gppapi_syncData,function(t){var e=t.account,o=t.customEvent;return r(void 0,void 0,void 0,(function(){var t,r,a,u,s,d,l,v,p,f,g,h,m,y,b;return i(this,(function(i){return(null!==(g=null===(f=null===(p=null===(v=o.detail)||void 0===v?void 0:v.eventListener)||void 0===p?void 0:p.pingData)||void 0===f?void 0:f.gppString)&&void 0!==g?g:"").length>0?(t=null===(m=null===(h=o.detail)||void 0===h?void 0:h.eventListener)||void 0===m?void 0:m.pingData,u="addEventListener"):(d=c(function(t){var e,n,o;try{var r=t.globalContext.__gpp("ping",(function(t,e){e&&"object"==typeof t&&(n=t)}));void 0===n&&(null!==(e=null==r?void 0:r.gppString)&&void 0!==e?e:"").length>0&&(n=r)}catch(t){o="E:ping: ".concat(t)}return[n,o]}(e),2),t=d[0],a=d[1],u="ping","object"!=typeof t&&(l=c(function(t){var e,o;try{var r=t.globalContext.__gpp("getGPPData");e=n(n({},r),r.pingData)}catch(t){o="E:getGPPData: ".concat(t)}return[e,o]}(e),2),t=l[0],r=l[1],u="getGPPData")),s={gpp:{gppLength:"string"==typeof(null==t?void 0:t.gppString)?t.gppString.length:void 0,isGPPTilde:(null!==(y=null==t?void 0:t.gppString)&&void 0!==y?y:"").includes("~"),error10:r,error:a,gppVersion:null==t?void 0:t.gppVersion,cmpId:null==t?void 0:t.cmpId,method:u,fromAddEvent:null===(b=o.detail)||void 0===b?void 0:b.fromAddEvent}},e.write(k,t),[2,{status:w.completed,analytics:s}]}))}))}],[M.consent_tcfapi_attemptSync,function(t){var e=t.account;return r(void 0,void 0,void 0,(function(){var t;return i(this,(function(n){return t=e.use(N),void 0===e.globalContext.__tcfapi||t?[2,w.cancelled]:(e.globalContext.__tcfapi("addEventListener",2,(function(t,n){e.record(M.consent_tcfapi_didChange,{tcData:t,success:n}).catch((function(t){}))})),[2,w.completed])}))}))}],[M.consent_tcfapi_didChange,function(t){var e=t.account,n=t.customEvent;return r(void 0,void 0,void 0,(function(){var t,o,r,a;return i(this,(function(i){return t=null===(r=n.detail)||void 0===r?void 0:r.success,e.update(N,(function(e){return e||!0===t})),o=null===(a=n.detail)||void 0===a?void 0:a.tcData,e.update(R,(function(e){return void 0!==o||!0===t?o:e})),"object"!=typeof o?[2,w.completed]:[2,{status:w.completed,analytics:T(e,o)}]}))}))}]]);function q(t,e){if("boolean"!=typeof t)throw new Error("must be a boolean")}function z(t){return function(e,n){null!=e&&t(e,n)}}function B(t,e,n){void 0===n&&(n="");var o={get:function(t,o){var r=Reflect.get(t,o),i=""!==n?"".concat(n,".").concat(String(o)):String(o),a=e[i];if(null!=a)try{a(r,i)}catch(t){throw new Error('Validation failed for "'.concat(i,'": ').concat(t.message))}return"object"!=typeof r||Array.isArray(r)?Array.isArray(r)?r.map((function(t,n){return B(t,e,"".concat(i,"[]"))})):r:B(r,e,i)},set:function(t,e){throw new Error('Cannot set property "'.concat(String(e),'": object is read-only'))},deleteProperty:function(t,e){throw new Error('Cannot delete property "'.concat(String(e),'": object is read-only'))},defineProperty:function(t,e){throw new Error('Cannot define property "'.concat(String(e),'": object is read-only'))},setPrototypeOf:function(t){throw new Error("Cannot set prototype: object is read-only")}};return new Proxy(t,o)}var F=function(){function t(t){var e=t.scope,n=t.object,o=t.action,r=t.validators,i=t.handler;this.throwIfInvalid(e,n,o),this.name="".concat(e,"/").concat(n,"/").concat(o),this.handler=this.wrapHandler(i,r)}return t.prototype.wrapHandler=function(t,e){var o=this;return function(a){return r(o,void 0,void 0,(function(){var o;return i(this,(function(r){switch(r.label){case 0:return o=a,void 0!==(null==e?void 0:e.detail)&&void 0!==a.customEvent.detail&&(o=n(n({},o),{detail:B(o.customEvent.detail,e.detail)})),[4,t(o)];case 1:return[2,r.sent()]}}))}))}},t.prototype.throwIfInvalid=function(t,e,n){var o=/^[a-z0-9][a-zA-Z0-9]*$/;if(!o.test(t)||!o.test(e)||!o.test(n))throw new Error("scope, object, and action must be alphanumeric and start with a lowercase. Received: ".concat(t,", ").concat(e,", ").concat(n));if(/[A-Z]/.test(n)&&!/^(will|did)/i.test(n))throw new Error("action must be a single verb (or a single verb prefixed by 'will' or 'did'). Received: ".concat(n))},t}();function J(t){if(new Set(t.map((function(t){return t.name}))).size!==t.length)throw new Error("Duplicates found");return new Map(t.map((function(t){return[t.name,t.handler]})))}var V="debugSession/end",G="prepend/events",H="populator/ran",W={key:"consent/hasPurposeOneConsent",default:!1},Q=function(){function t(t){var e=this;this.getItem=function(t){var n=e.globalContext.document.cookie.split("; ").reduce((function(e,n){var o=n.split("=");return o[0]===t?decodeURIComponent(o.slice(1).join("=")):e}),"");return n.length>0?n:null},this.removeItem=function(t,n){void 0===n&&(n="/"),e.setItem(t,"",0,n)},this.setItem=function(t,n,o,r){void 0===r&&(r="/");var i=new Date(o);if(!e.isValidDate(i))throw new Error("Invalid expiration date");e.globalContext.document.cookie="".concat(t,"=").concat(n,"; expires=").concat(i.toUTCString(),"; path=").concat(r,";")},this.globalContext=t}return t.prototype.isValidDate=function(t){return t instanceof Date&&!isNaN(t)},t}(),K=["scope/objectName",V,G];function Y(t){return null===t||"object"!=typeof t?t:t instanceof Date?new Date(t.getTime()):t instanceof Array?t.reduce((function(t,e){return t.push(Y(e)),t}),[]):t instanceof Set?Array.from(t.values()).reduce((function(t,e){return t.add(Y(e)),t}),new Set):t instanceof Map?Array.from(t.entries()).reduce((function(t,e){return t.set(e[0],Y(e[1])),t}),new Map):t instanceof Object?Object.keys(t).reduce((function(e,n){return e[n]=Y(t[n]),e}),{}):t}var X=function(){function t(t,e){var n,o,r=null!==(n=null==e?void 0:e.rootName)&&void 0!==n?n:ft.rootName;this.globalContext=null!==(o=null==e?void 0:e.globalContext)&&void 0!==o?o:ft.globalContext;var i=this.globalContext[r].get(t);if(null==i)throw new Error('Missing "'.concat(t,'" account in userspace object'));this.id=t,this.store=i.store,this.queue=i.queue}return t.prototype.record=function(t,e){return r(this,void 0,void 0,(function(){var o=this;return i(this,(function(r){switch(r.label){case 0:return[4,new Promise((function(r,i){o.queue.push(new CustomEvent(t,{detail:n({resolve:r,reject:i,source:b.internal},e)}))}))];case 1:return[2,r.sent()]}}))}))},t.prototype.recordListener=function(t,e){return r(this,void 0,void 0,(function(){var o=this;return i(this,(function(r){switch(r.label){case 0:return[4,new Promise((function(r,i){o.queue.push(new CustomEvent(t.name,{detail:n({resolve:r,reject:i,source:b.internal},e)}))}))];case 1:return[2,r.sent()]}}))}))},t.prototype.recordListenerNonBlocking=function(t,e){this.recordListener(t,e).catch((function(t){}))},t.prototype.read=function(t,e){var n,o,r,i,a=this.store.get(t);if(void 0!==a)return a;if(void 0!==(null==e?void 0:e.persist)&&e.persist){var s=this.readLocalStorage(t,{usePrefix:!0});if(void 0!==s)return s}var d=null===(o=null===(n=null==e?void 0:e.default)||void 0===n?void 0:n.generators)||void 0===o?void 0:o.get(t);return void 0!==d?d.apply(void 0,u([],c(null!==(i=null===(r=null==e?void 0:e.default)||void 0===r?void 0:r.args)&&void 0!==i?i:[]),!1)):void 0},t.prototype.write=function(t,e,n){this.store.set(t,e),void 0!==(null==n?void 0:n.persist)&&n.persist&&this.writeLocalStorage(t,e,{usePrefix:!0})},t.prototype.use=function(t,e){var n,o=this.store.get(t.key);if(void 0!==o)n=o;else if(void 0!==(null==e?void 0:e.persist)&&e.persist){var r=this.readLocalStorage(t.key,{usePrefix:!0});null!=r&&(n=r)}var i=null!=n?n:t.default;if("function"==typeof i||!1===(null==e?void 0:e.structuredClone))return i;try{return structuredClone(i)}catch(t){try{return Y(i)}catch(t){return C.logCoreError({id:"Core.library.Account.use",account:null,error:t}),i}}},t.prototype.update=function(t,e,n){var o=e(this.use(t,n));if(void 0!==t.postProcessor&&(o=t.postProcessor(o)),this.store.set(t.key,o),void 0!==(null==n?void 0:n.persist)&&n.persist){if("string"!=typeof o)throw new Error("".concat(JSON.stringify(o)," must be a string to be writtable to browser storage"));this.writeLocalStorage(t.key,o,{usePrefix:!0})}},t.prototype.delete=function(t,e){this.store.delete(t),void 0!==(null==e?void 0:e.persist)&&e.persist&&this.deleteLocalStorage(t,{usePrefix:!0})},t.prototype.remove=function(t,e){this.store.delete(t.key),void 0!==(null==e?void 0:e.persist)&&e.persist&&this.deleteLocalStorage(t.key,{usePrefix:!0})},t.prototype.executeFuncWithConsent=function(t,e){if(!this.isAllowedToAccessInfoOnDevice())throw new Error("Invalid consent. API requires consent before execution.");return e.apply(t)},t.prototype.recordErrorEvent=function(t){C.logError(n(n({},t),{account:this}))},t.prototype.recordStatusChangeEvent=function(t){C.logFeature({id:t.id,account:this,feature:t.status,props:n({},t.props)})},t.prototype.recordGenericEvent=function(t){C.logFeature({id:t.id,account:this,feature:t.id,props:n({},t.props)})},t.prototype.isAllowedToAccessInfoOnDevice=function(){return this.updateUserConsent(),this.use(W)},t.prototype.isAPStagAllowedToAccessInfoOnDevice=function(){return!0===this.globalContext.apstag._atsaaiod()},t.prototype.updateUserConsent=function(){try{var t=this.isAPStagAllowedToAccessInfoOnDevice();this.update(W,(function(){return t}))}catch(t){}},t.prototype.getPersistedItemName=function(t){return"".concat("aps").concat(":").concat(this.id).concat(":").concat(t)},t.prototype.isBrowserStorageAllowed=function(t){var e=!1;try{e=this.isAllowedToAccessInfoOnDevice()}catch(t){}return e||K.includes(t)},t.prototype.readCookieStorage=function(t,e){var n;if(!this.isBrowserStorageAllowed(t))throw new Error("".concat(t," is not allowed to be read from cookie storage"));var o=null!==(n=null==e?void 0:e.usePrefix)&&void 0!==n&&n?this.getPersistedItemName(t):t;return new Q(this.globalContext).getItem(o)},t.prototype.readLocalStorage=function(t,e){var n;if(!this.isBrowserStorageAllowed(t))throw new Error("".concat(t," is not allowed to be read from browser storage"));var o=null!==(n=null==e?void 0:e.usePrefix)&&void 0!==n&&n?this.getPersistedItemName(t):t;if(o in this.globalContext.localStorage)return this.globalContext.localStorage.getItem(o)},t.prototype.writeLocalStorage=function(t,e,n){var o;if(!this.isBrowserStorageAllowed(t))throw new Error("".concat(t," is not allowed to be written to browser storage"));if("string"!=typeof e)throw new Error("".concat(JSON.stringify(e)," must be a string to be writtable to browser storage"));var r=null!==(o=null==n?void 0:n.usePrefix)&&void 0!==o&&o?this.getPersistedItemName(t):t;this.globalContext.localStorage.setItem(r,e)},t.prototype.deleteLocalStorage=function(t,e){var n;if(!this.isBrowserStorageAllowed(t))throw new Error("".concat(t," is not allowed to be touched/deleted in browser storage"));var o=null!==(n=null==e?void 0:e.usePrefix)&&void 0!==n&&n?this.getPersistedItemName(t):t;this.globalContext.localStorage.removeItem(o)},t.prototype.readSessionStorage=function(t,e){var n;if(!this.isBrowserStorageAllowed(t))throw new Error("".concat(t," is not allowed to be read from browser storage"));var o=null!==(n=null==e?void 0:e.usePrefix)&&void 0!==n&&n?this.getPersistedItemName(t):t;if(o in this.globalContext.sessionStorage)return this.globalContext.sessionStorage.getItem(o)},t.prototype.writeSessionStorage=function(t,e,n){var o;if(!this.isBrowserStorageAllowed(t))throw new Error("".concat(t," is not allowed to be written to browser storage"));if("string"!=typeof e)throw new Error("".concat(JSON.stringify(e)," must be a string to be writable to browser storage"));var r=null!==(o=null==n?void 0:n.usePrefix)&&void 0!==o&&o?this.getPersistedItemName(t):t;this.globalContext.sessionStorage.setItem(r,e)},t.prototype.deleteSessionStorage=function(t,e){var n;if(!this.isBrowserStorageAllowed(t))throw new Error("".concat(t," is not allowed to be touched/deleted in browser storage"));var o=null!==(n=null==e?void 0:e.usePrefix)&&void 0!==n&&n?this.getPersistedItemName(t):t;this.globalContext.sessionStorage.removeItem(o)},t}(),Z="_system",$=function(t){function n(e,n){return t.call(this,Z,{globalContext:e,rootName:n})||this}return e(n,t),n}(X);function tt(t){var e=function(t,e){throw void 0!==t.context?t.context="".concat(e," > ").concat(t.context):t.context=e,t};return function(n,o,r){var i=r.value;return r.value=function(){for(var n=[],o=0;o150){var o=n.slice(-100);t.store.set(l,o)}}},t.prototype.recordProcessedEvents=function(t){var e,n=null!==(e=t.store.get(l))&&void 0!==e?e:[];n.push.apply(n,u([],c(t.queue.filter((function(t){return void 0!==t.status&&ut.includes(t.status)}))),!1)),t.store.set(l,n)},t.prototype.cleanUpAccountQueue=function(t){var e;(e=t.queue).splice.apply(e,u([0,t.queue.length],c(t.queue.filter((function(t){return void 0===t.status||!ut.includes(t.status)}))),!1))},t.prototype.archive=function(){var t=this;this.getAccounts().forEach((function(e){t.recordProcessedEvents(e),t.limitHistoryLength(e),t.cleanUpAccountQueue(e)}))},t.prototype.filterExternalEvents=function(t){return null==t?void 0:t.filter((function(t){var e,n;return(null===(e=t.detail)||void 0===e?void 0:e.source)!==b.internal&&(null===(n=t.detail)||void 0===n?void 0:n.source)!==b.apstag&&t.status!==I.waiting}))},t.prototype.getNumberOfExternalEvents=function(t){var e,n=this.filterExternalEvents(t);return null!==(e=null==n?void 0:n.length)&&void 0!==e?e:0},t.prototype.updateExternalEventCount=function(t){var e=this.getNumberOfExternalEvents(t);this.incrementStoreItemCountBy(f,e)},t.prototype.throwOnInfiniteLoop=function(){var t=this,e=g;this.incrementStoreItemCountBy(e,1);var n=this.readStoreItemCount(e);if(n>1e4)throw new Error("Too many dispatches. Aborting");n%100==0&&(new $).recordGenericEvent({id:"Core.library.Dispatcher.throwOnInfiniteLoop",props:{recentDispatchesCount:n}}),setTimeout((function(){t.resetStoreItemCount(e)}),100)},t.prototype.dispatch=function(t){var e,n,o,r,i,a=this,c=t.reason;try{this.throwOnInfiniteLoop(),m()&&rt.info('# Dispatch from method "'.concat(c.method,'" on event "').concat(null!==(n=null===(e=c.events)||void 0===e?void 0:e[0].type)&&void 0!==n?n:"undefined",'" with source "').concat(null!==(i=null===(r=null===(o=c.events)||void 0===o?void 0:o[0].detail)||void 0===r?void 0:r.source)&&void 0!==i?i:"undefined",'"\n_________________________________________')),this.updateExternalEventCount(c.events),this.getAccounts().forEach((function(t){return a.dispatchAccount(t,c)})),this.archive()}catch(t){throw(new $).recordErrorEvent({id:"Core.library.Dispatcher.dispatch",error:t}),t}},t}(),dt=function(){function t(t,e){this.globalContext=t,this.rootName=e}return t.prototype.subscribe=function(t){try{var e=new $,n=null!=e.store.get(d)?e.store.get(d):new Map;e.store.set(d,new Map(u(u([],c(n),!1),c(t),!1)))}catch(t){throw(new $).recordErrorEvent({id:"Core.library.Subscriber.subscribe",error:t}),t}},t}(),lt=function(){function t(t,e){this.globalContext=t,this.rootName=e}return t.prototype.populate=function(){try{var t=new $,e=!1;try{e=JSON.parse(t.read(H))}catch(t){}if(e)return;t.write(H,JSON.stringify(!0)),this.populateFromPrependStore(),this.populateFromQueryParams()}catch(t){(new $).recordErrorEvent({id:"Core.library.Populator.populate",error:t})}},t.prototype.populateFromPrependStore=function(){var t=this;this.globalContext[this.rootName].forEach((function(e,n){var o,r,i=new X(n,{globalContext:t.globalContext,rootName:t.rootName}),a=null!==(r=i.read(G,{persist:!0}))&&void 0!==r?r:"[]";i.write(G,JSON.stringify([]));try{var s=JSON.parse(a);if(0===s.length)return;(o=i.queue).push.apply(o,u([],c(s.map(pt)),!1))}catch(t){console.error("Error processing prepended events",t)}}))},t.prototype.populateFromQueryParams=function(){var t,e,n=null===(e=null===(t=this.globalContext)||void 0===t?void 0:t.location)||void 0===e?void 0:e.search,o=new URLSearchParams(n),r=this.globalContext[this.rootName],i=r.get(Z);vt(o,"aps.trigger").forEach((function(t){i.queue.push(pt(t))})),vt(o,"aps.triggerFor",!0).forEach((function(t){void 0!==t.accountId&&r.has(t.accountId)&&r.get(t.accountId).queue.push(pt(t))}));var a=vt(o,"aps_event");r.forEach((function(t){a.forEach((function(e){t.queue.push(pt(e))}))}))},t}(),vt=function(t,e,n){void 0===n&&(n=!1);var o=t.getAll(e),r=[];return o.forEach((function(t){var e,o=t.split(",");n&&(e=o.shift());var i=o.shift();if(void 0!==i&&i.length>0){var a=decodeURIComponent(o.join(",")),c=void 0;if(a.length>0)try{c=JSON.parse(a)}catch(t){console.error("Error processing query param event",i,c)}r.push({eventName:i.replace(/_/g,"/"),eventDetail:c,accountId:e})}})),r},pt=function(t){var e;return new CustomEvent(t.eventName,{detail:n({},null!==(e=t.eventDetail)&&void 0!==e?e:{})})},ft={globalContext:window,rootName:"_aps"},gt=function(){function t(t){this.ID=t,this.clear()}return t.prototype.clear=function(){var t=this;(new $).update(at,(function(e){return e.delete(t.ID),e}))},t.prototype.recordListener=function(t,e){var n=this;(new $).update(at,(function(o){var r=o.get(n.ID);return void 0!==r?r.push([t.name,e]):o.set(n.ID,[[t.name,e]]),o}))},t}(),ht=function(){function t(t,e){void 0===t&&(t=ft.globalContext),void 0===e&&(e=ft.rootName),this.dispatcher=new st(t,e),this.equiper=new nt(t,e,this.dispatcher),this.subscriber=new dt(t,e),this.populator=new lt(t,e),this.globalContext=t,this.rootName=e}return t.prototype.createAccount=function(t){var e;if(void 0===t)throw new Error("accountID must be provided");this.globalContext[this.rootName]=null!==(e=this.globalContext[this.rootName])&&void 0!==e?e:new Map;var n=this.globalContext[this.rootName],o={store:new Map,queue:[]};return!1===n.has(t)&&n.set(t,o),new X(t,{globalContext:this.globalContext,rootName:this.rootName})},t.prototype.subscribe=function(t){this.subscriber.subscribe(t)},t.prototype.equip=function(){this.equiper.equip()},t.prototype.dispatch=function(t){var e=t.reason;this.dispatcher.dispatch({reason:e})},t.prototype.populate=function(){this.populator.populate()},t.prototype.load=function(t){var e=t.listeners;this.equip(),this.subscribe(e),this.dispatch({reason:{method:y.direct}}),this.populate()},t.prototype.registerEventSource=function(t){return this.equip(),new gt(t)},o([tt("HASH#Core.library.UserSpace.subscribe")],t.prototype,"subscribe",null),o([tt("HASH#Core.library.UserSpace.equip")],t.prototype,"equip",null),o([tt("HASH#Core.library.UserSpace.dispatch")],t.prototype,"dispatch",null),o([tt("HASH#Core.library.UserSpace.populate")],t.prototype,"populate",null),o([tt("HASH#Core.library.UserSpace.load")],t.prototype,"load",null),o([tt("HASH#Core.library.UserSpace.registerEventSource")],t.prototype,"registerEventSource",null),t}(),mt="vnd_prx_segments",yt="aps_targeting_comscore",bt=new F({scope:"cxm",object:"comscore",action:"set",handler:function(t){var e=t.account;return t.customEvent,r(void 0,void 0,void 0,(function(){return i(this,(function(t){return[2,{status:wt(e)}]}))}))}}),wt=function(t){var e=t.readSessionStorage(yt);if(t.deleteSessionStorage(yt),null==e)return w.cancelled;try{var n=JSON.parse(e)[mt];if(null==n)throw new Error;return t.globalContext.googletag.pubads().getSlots().forEach((function(t){t.setTargeting(mt,n)})),w.completed}catch(t){throw new Error("Malformed targeting object at ".concat(yt))}},Et="aps_targeting_ias",_t=new F({scope:"cxm",object:"ias",action:"set",handler:function(t){var e=t.account;return t.customEvent,r(void 0,void 0,void 0,(function(){return i(this,(function(t){return[2,{status:St(e)}]}))}))}}),St=function(t){var e=t.readSessionStorage(Et);if(t.deleteSessionStorage(Et),null==e)return w.cancelled;try{var n=JSON.parse(e),o=t.globalContext.googletag;o.pubads().getSlots().forEach((function(t){var e=n.targeting.slots[t.getSlotElementId()];null!=e&&Object.keys(e).forEach((function(n){t.setTargeting(n,e[n])}))}));var r=n.targeting,i=r.brandSafety,a=r.fr,c=r.custom;return null!=i&&Object.keys(i).forEach((function(t){o.pubads().setTargeting(t,i[t])})),null!=c&&Object.keys(c).forEach((function(t){var e=c[t];Array.isArray(e)?e.forEach((function(e){o.pubads().setTargeting(t,e)})):o.pubads().setTargeting(t,e)})),null!=a&&o.pubads().setTargeting("fr",a),w.completed}catch(t){throw new Error("Malformed targeting object at ".concat(Et))}},xt="aps_targeting_illuma",Ct=new F({scope:"cxm",object:"illuma",action:"set",handler:function(t){var e=t.account;return t.customEvent,r(void 0,void 0,void 0,(function(){return i(this,(function(t){return[2,{status:It(e)}]}))}))}}),It=function(t){var e=t.readSessionStorage(xt);if(t.deleteSessionStorage(xt),null==e)return w.cancelled;var n=JSON.parse(e).results;if(null==n)throw new Error("Malformed targeting object at ".concat(xt));var o=t.globalContext.googletag;return Object.keys(n).forEach((function(t){var e=n[t];o.pubads().setTargeting("".concat("illuma_").concat(t),JSON.stringify(e))})),w.completed},Pt=new F({scope:"cxm",object:"contextual",action:"set",handler:function(t){var e=t.account;return t.customEvent,r(void 0,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,Promise.all([e.recordListener(bt),e.recordListener(_t),e.recordListener(Ct)])];case 1:return t.sent(),[2,{status:w.completed}]}}))}))}}),At=J([bt,Pt,_t,Ct]),Lt={key:"customPlacement/configuration",default:void 0},kt={key:"customPlacement/contextURL",default:void 0},Dt={key:"customPlacement/configurationEndpoint",default:"https://aax.amazon-adsystem.com/e/placements"},Nt={key:"ad/context",default:void 0};function Rt(t){var e=t.use(Nt);return void 0!==e&&"user"in e?(e.user,function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r0)||(function(t,e,n){var o,r=t.globalContext.document.createElement("iframe"),i=e.size.split("x");Object.assign(r.style,{marginLeft:"0",marginTop:"0",height:"".concat(i[1],"px"),width:"100%"}),r.setAttribute("scrolling","no"),r.setAttribute("frameborder","0"),n.appendChild(r);var a=null===(o=r.contentWindow)||void 0===o?void 0:o.document;void 0!==a&&(a.open(),a.write('